<!DOCTYPE html>
<html>
<head>
    <title>我的游记日报</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap/js/bootstrap.min.js"></script>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/userTravels.css"/>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css"/>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script>
        $(function () {
            var user = JSON.parse(sessionStorage.getItem("user"));
            function query() {
                $.get("/users/" + user.id + "/dailys", {currentPage: currentPage},function (data) {
                    dataList = $.merge(dataList,data.list);
                    $('.dailys').renderValues({list:dataList},{
                        // 拼接id到超链接
                        setHref:function (item, value) {
                            var href = "/mine/editDailys.html?id=" + value;
                            console.log(href);
                            $(item).attr('href',href);
                        }
                    });
                    currentPage += 1;
                    totalPage = data.pages;
                });
            }
            // 解决上一页数据丢失问题
            var dataList = [];
            var currentPage = 1;
            var totalPage = 1;
            query();
            //屏幕滚动事件
            $(window).scroll(function () {
                // html 页面的高度
                // 设备屏幕的高度
                // 滑动的高度
                // 达到底部时翻页
                if($(window).height() + $(document).scrollTop() + 1 >= $(document).height()){
                    // 解决底部翻页问题
                    if(currentPage <= totalPage){
                        query();
                    } else{
                        $(document).dialog({
                            type : 'notice',
                            infoText: '深不见底还是到底啦~',
                            autoClose: 2500,
                            position: 'bottom'  // center: 居中; bottom: 底部
                        });
                    }
                }
            });
        });

    </script>
</head>
<body>
<div class="search-head">
    <div class="row nav-search">
        <div class="col">
            <a href="javascript:window.history.go(-1);">
                <span><i class="fa fa-chevron-left"></i></span>
            </a>
        </div>
        <div class="col">
            <span>我的游记日报</span>
        </div>
        <div class="col"></div>
    </div>
</div>
<div class="container dailys">
    <dl class="list" render-loop="list">
        <dd>
            <a render-fun="setHref" render-key="list.id">
                <img render-src="list.coverUrl">
                <h6 class="title" render-html="list.title"></h6>
                <p>最近创建时间 <span render-html="list.createTime"></span>
                </p>
            </a>
        </dd>
    </dl>
</div>
</body>
</html>
